import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia'

  export const useComponents = defineStore('components', () => {
    const canvasComponents = ref<Array<any>>([])
    const currentComponent = ref(null)
    const setCurrentComponents = (obj: any) => {
        canvasComponents.value.push= obj
        console.log(canvasComponents,"数组");
        
    }
    const  currentcom=ref([])

    //dy种草
    const setCurrentCom=(id:string)=>{
        const obj=canvasComponents.value.find((item)=>item.id===id)
        currentcom.value=obj
    }
    //yangshi
    const setStyle=(id:string,value:string,key:string)=>{
        const obj=canvasComponents.value.find((item)=>item.id===id)
        obj.style[key]=value
    }
    return {
        canvasComponents,
        currentComponent,
        setCurrentComponents,
        setCurrentCom,
        setStyle
        // setStyle
    }
})
export default useComponents
